#pragma once

#include "widgets.h"
#include <QColor>
#include <QPoint>
#include <QFrame>
#include <QMouseEvent>
#include <QLabel>
#include <vector>
#include <map>

class STabLabel : public QLabel
{
	Q_OBJECT
public:
	STabLabel(const QString&, QWidget* parent = nullptr);
	~STabLabel();
	void setIndex(int v) { m_index = v; }  
	int index() const {return m_index;}
	void setImgName(QString imgName) { m_imgName = imgName; }
	void setImgTip(QString imgTip) { m_imgTip = imgTip; }

Q_SIGNALS:
	void clicked(int);

protected:
	void mousePressEvent(QMouseEvent* event) override;
	void paintEvent(QPaintEvent*) override;
	void mouseMoveEvent(QMouseEvent* event) override;

private:
	int			m_index = 0;
	QString		m_imgName;
	QString		m_imgTip;
	QRect		m_ImageRect;
};

class S_WIDGETS_EXPORT STabCtrl : public QFrame
{
	Q_OBJECT

public:
	STabCtrl(QWidget* p);
	void addTab(const QString& name, const QString& tip = "");
	void setTabBkColor(int index, QColor color);
	void setTabInfo(int index, const QString& imgName,const QString& tip = "");
	void selectTab(int index);
	void setTabDisabled(int index);
	void setTabText(int index,const QString& name);
	int	 getTabCount();
	int  getSelTab();
	void setTabData(int index, QVariant v);
	QVariant tabData(int index);

signals:
	void tabSelected(int index);

protected:
	void showEvent(QShowEvent* event) override;

protected Q_SLOTS:
	void onTabClicked(int);

private:
	std::vector<STabLabel*> m_labels;
	std::map<int,QColor>	m_bkColors;
	QString		m_styleSheet;
	int			m_selIndex = -1;
};
